3ddb79bcOMCu9-5mKpjIh5d0qqBDPg xen/arch/i386/xeno.lds
3ddb79bdff-gj-jFGKjOejeHLqL8Lg xen/common/Makefile
3e397e66AyyD5fYraAySWuwi9uqSXg xen/common/ac_timer.c
-3ddb79bddEYJbcURvqqcx99Yl2iAhQ xen/common/block.c
3ddb79bdrqnW93GR9gZk1OJe1qK-iQ xen/common/brlock.c
3fb10d07GscSWPKxBqpvNfU-dYfa0g xen/common/console.c
4022a73c_BbDFd2YJ_NQYVvKX5Oz7w xen/common/debug-linux.c
#ifndef __XC_H__
#define __XC_H__
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned long u32;
+typedef unsigned long long u64;
+typedef signed char s8;
+typedef signed short s16;
+typedef signed long s32;
+typedef signed long long s64;
+
/* Obtain or relinquish a handle on the 'xc' library. */
int xc_interface_open(void);
int xc_interface_close(int xc_handle);
typedef struct {
- unsigned int domid;
+ u64 domid;
unsigned int cpu;
int has_cpu;
int stopped;
int xc_domain_create(int xc_handle,
unsigned int mem_kb,
- const char *name);
+ const char *name,
+ u64 *pdomid);
int xc_domain_start(int xc_handle,
- unsigned int domid);
+ u64 domid);
int xc_domain_stop(int xc_handle,
- unsigned int domid);
+ u64 domid);
int xc_domain_destroy(int xc_handle,
- unsigned int domid,
+ u64 domid,
int force);
int xc_domain_pincpu(int xc_handle,
- unsigned int domid,
+ u64 domid,
int cpu);
int xc_domain_getinfo(int xc_handle,
- unsigned int first_domid,
+ u64 first_domid,
unsigned int max_doms,
xc_dominfo_t *info);
int xc_linux_save(int xc_handle,
- unsigned int domid,
+ u64 domid,
const char *state_file,
int verbose);
int xc_linux_restore(int xc_handle,
const char *state_file,
- int verbose);
+ int verbose,
+ u64 *pdomid);
int xc_linux_build(int xc_handle,
- unsigned int domid,
+ u64 domid,
const char *image_name,
const char *ramdisk_name,
const char *cmdline);
int xc_netbsd_build(int xc_handle,
- unsigned int domid,
+ u64 domid,
const char *image_name,
const char *cmdline);
int xc_bvtsched_global_set(int xc_handle,
unsigned long ctx_allow);
int xc_bvtsched_domain_set(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned long mcuadv,
unsigned long warp,
unsigned long warpl,
} xc_vif_stats_t;
int xc_vif_scheduler_set(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned int vifid,
xc_vif_sched_params_t *params);
int xc_vif_scheduler_get(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned int vifid,
xc_vif_sched_params_t *params);
int xc_vif_stats_get(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned int vifid,
xc_vif_stats_t *stats);
typedef struct {
-#define XC_VBDDOM_PROBE_ALL (~0U)
- unsigned int domid;
+#define XC_VBDDOM_PROBE_ALL (~0ULL)
+ u64 domid;
unsigned short vbdid;
#define XC_VBDF_WRITEABLE (1<<0)
unsigned long flags;
} xc_vbdextent_t;
int xc_vbd_create(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned short vbdid,
int writeable);
int xc_vbd_destroy(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned short vbdid);
int xc_vbd_grow(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned short vbdid,
xc_vbdextent_t *extent);
int xc_vbd_shrink(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned short vbdid);
int xc_vbd_setextents(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned short vbdid,
unsigned int nr_extents,
xc_vbdextent_t *extents);
int xc_vbd_getextents(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned short vbdid,
unsigned int max_extents,
xc_vbdextent_t *extents,
int *writeable);
int xc_vbd_probe(int xc_handle,
- unsigned int domid,
+ u64 domid,
unsigned int max_vbds,
xc_vbd_t *vbds);
}
int xc_bvtsched_domain_set(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned long mcuadv,
unsigned long warp,
unsigned long warpl,
int xc_domain_create(int xc_handle,
unsigned int mem_kb,
- const char *name)
+ const char *name,
+ domid_t *pdomid)
{
int err;
dom0_op_t op;
strncpy(op.u.createdomain.name, name, MAX_DOMAIN_NAME);
op.u.createdomain.name[MAX_DOMAIN_NAME-1] = '\0';
- err = do_dom0_op(xc_handle, &op);
+ if ( (err = do_dom0_op(xc_handle, &op)) == 0 )
+ *pdomid = op.u.createdomain.domain;
- return (err < 0) ? err : op.u.createdomain.domain;
+ return err;
}
int xc_domain_start(int xc_handle,
- unsigned int domid)
+ domid_t domid)
{
dom0_op_t op;
op.cmd = DOM0_STARTDOMAIN;
int xc_domain_stop(int xc_handle,
- unsigned int domid)
+ domid_t domid)
{
dom0_op_t op;
op.cmd = DOM0_STOPDOMAIN;
int xc_domain_destroy(int xc_handle,
- unsigned int domid,
+ domid_t domid,
int force)
{
dom0_op_t op;
}
int xc_domain_pincpu(int xc_handle,
- unsigned int domid,
- int cpu)
+ domid_t domid,
+ int cpu)
{
dom0_op_t op;
op.cmd = DOM0_PINCPUDOMAIN;
int xc_domain_getinfo(int xc_handle,
- unsigned int first_domid,
+ domid_t first_domid,
unsigned int max_doms,
xc_dominfo_t *info)
{
- unsigned int nr_doms, next_domid = first_domid;
+ unsigned int nr_doms;
+ domid_t next_domid = first_domid;
dom0_op_t op;
for ( nr_doms = 0; nr_doms < max_doms; nr_doms++ )
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
-static long get_tot_pages(int xc_handle, int domid)
+static long get_tot_pages(int xc_handle, domid_t domid)
{
dom0_op_t op;
op.cmd = DOM0_GETDOMAININFO;
}
static int get_pfn_list(int xc_handle,
- int domid,
+ domid_t domid,
unsigned long *pfn_buf,
unsigned long max_pfns)
{
}
static int setup_guestos(int xc_handle,
- int dom,
+ domid_t dom,
gzFile kernel_gfd,
gzFile initrd_gfd,
unsigned long tot_pages,
start_info->mod_len = initrd_len;
start_info->nr_pages = tot_pages;
start_info->shared_info = shared_info_frame << PAGE_SHIFT;
- start_info->dom_id = dom;
start_info->flags = 0;
strncpy(start_info->cmd_line, cmdline, MAX_CMD_LEN);
start_info->cmd_line[MAX_CMD_LEN-1] = '\0';
}
int xc_linux_build(int xc_handle,
- unsigned int domid,
+ domid_t domid,
const char *image_name,
const char *ramdisk_name,
const char *cmdline)
} while ( 0 )
static int get_pfn_list(int xc_handle,
- int domain_id,
+ domid_t domain_id,
unsigned long *pfn_buf,
unsigned long max_pfns)
{
int xc_linux_restore(int xc_handle,
const char *state_file,
- int verbose)
+ int verbose,
+ domid_t *pdomid)
{
dom0_op_t op;
int rc = 1, i, j;
- unsigned long mfn, pfn, dom = 0;
+ unsigned long mfn, pfn;
+ domid_t dom = 0;
unsigned int prev_pc, this_pc;
/* Number of page frames in use by this XenoLinux session. */
p_srec = map_pfn(pm_handle, mfn);
p_srec->resume_info.nr_pages = nr_pfns;
p_srec->resume_info.shared_info = shared_info_frame << PAGE_SHIFT;
- p_srec->resume_info.dom_id = dom;
p_srec->resume_info.flags = 0;
unmap_pfn(pm_handle, p_srec);
else
{
/* Success: print the domain id. */
- verbose_printf("DOM=%ld\n", dom);
+ verbose_printf("DOM=%llu\n", dom);
}
if ( pm_handle >= 0 )
gzclose(gfd);
- return (rc == 0) ? dom : rc;
+ if ( rc == 0 )
+ *pdomid = dom;
+
+ return rc;
}
static int check_pfn_ownership(int xc_handle,
unsigned long mfn,
- unsigned int dom)
+ domid_t dom)
{
dom0_op_t op;
op.cmd = DOM0_GETPAGEFRAMEINFO;
#define GETPFN_ERR (~0U)
static unsigned int get_pfn_type(int xc_handle,
unsigned long mfn,
- unsigned int dom)
+ domid_t dom)
{
dom0_op_t op;
op.cmd = DOM0_GETPAGEFRAMEINFO;
}
int xc_linux_save(int xc_handle,
- unsigned int domid,
+ domid_t domid,
const char *state_file,
int verbose)
{
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
-static long get_tot_pages(int xc_handle, int domid)
+static long get_tot_pages(int xc_handle, domid_t domid)
{
dom0_op_t op;
op.cmd = DOM0_GETDOMAININFO;
}
static int get_pfn_list(int xc_handle,
- int domid,
+ domid_t domid,
unsigned long *pfn_buf,
unsigned long max_pfns)
{
}
static int setup_guestos(int xc_handle,
- int dom,
+ domid_t dom,
gzFile kernel_gfd,
unsigned long tot_pages,
unsigned long *virt_startinfo_addr,
start_info->mod_len = symtab_len;
start_info->nr_pages = tot_pages;
start_info->shared_info = shared_info_frame << PAGE_SHIFT;
- start_info->dom_id = dom;
start_info->flags = 0;
strncpy(start_info->cmd_line, cmdline, MAX_CMD_LEN);
start_info->cmd_line[MAX_CMD_LEN-1] = '\0';
}
int xc_netbsd_build(int xc_handle,
- unsigned int domid,
+ domid_t domid,
const char *image_name,
const char *cmdline)
{
#ifndef __XC_PRIVATE_H__
#define __XC_PRIVATE_H__
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned long u32;
-typedef unsigned long long u64;
-typedef signed char s8;
-typedef signed short s16;
-typedef signed long s32;
-typedef signed long long s64;
-
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include "xc_private.h"
int xc_vbd_create(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned short vbdid,
int writeable)
{
int xc_vbd_destroy(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned short vbdid)
{
block_io_op_t op;
int xc_vbd_grow(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned short vbdid,
xc_vbdextent_t *extent)
{
int xc_vbd_shrink(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned short vbdid)
{
block_io_op_t op;
int xc_vbd_setextents(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned short vbdid,
unsigned int nr_extents,
xc_vbdextent_t *extents)
int xc_vbd_getextents(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned short vbdid,
unsigned int max_extents,
xc_vbdextent_t *extents,
int xc_vbd_probe(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned int max_vbds,
xc_vbd_t *vbds)
{
#include "xc_private.h"
int xc_vif_scheduler_set(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned int vifid,
xc_vif_sched_params_t *params)
{
int xc_vif_scheduler_get(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned int vifid,
xc_vif_sched_params_t *params)
{
int xc_vif_stats_get(int xc_handle,
- unsigned int domid,
+ domid_t domid,
unsigned int vifid,
xc_vif_stats_t *stats)
{
unsigned int mem_kb = 65536;
char *name = "(anon)";
+ u64 dom;
int ret;
static char *kwd_list[] = { "mem_kb", "name", NULL };
&mem_kb, &name) )
return NULL;
- ret = xc_domain_create(xc->xc_handle, mem_kb, name);
-
- return PyInt_FromLong(ret);
+ if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, &dom)) < 0 )
+ return PyLong_FromLong(ret);
+
+ return PyLong_FromUnsignedLongLong(dom);
}
static PyObject *pyxc_domain_start(PyObject *self,
{
XcObject *xc = (XcObject *)self;
- unsigned int dom;
- int ret;
+ u64 dom;
+ int ret;
static char *kwd_list[] = { "dom", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &dom) )
return NULL;
ret = xc_domain_start(xc->xc_handle, dom);
{
XcObject *xc = (XcObject *)self;
- unsigned int dom;
- int ret;
+ u64 dom;
+ int ret;
static char *kwd_list[] = { "dom", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &dom) )
return NULL;
ret = xc_domain_stop(xc->xc_handle, dom);
{
XcObject *xc = (XcObject *)self;
- unsigned int dom;
- int force = 0, ret;
+ u64 dom;
+ int force = 0, ret;
static char *kwd_list[] = { "dom", "force", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L|i", kwd_list,
&dom, &force) )
return NULL;
{
XcObject *xc = (XcObject *)self;
- unsigned int dom;
- int cpu, ret;
+ u64 dom;
+ int cpu = -1, ret;
static char *kwd_list[] = { "dom", "cpu", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L|i", kwd_list,
&dom, &cpu) )
return NULL;
XcObject *xc = (XcObject *)self;
PyObject *list;
- unsigned int first_dom = 0, max_doms = 1024;
- int nr_doms, i;
+ u64 first_dom = 0;
+ int max_doms = 1024, nr_doms, i;
xc_dominfo_t *info;
static char *kwd_list[] = { "first_dom", "max_doms", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|Li", kwd_list,
&first_dom, &max_doms) )
return NULL;
{
PyList_SetItem(
list, i,
- Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:L,s:s}",
+ Py_BuildValue("{s:L,s:i,s:i,s:i,s:l,s:L,s:s}",
"dom", info[i].domid,
"cpu", info[i].cpu,
"running", info[i].has_cpu,
{
XcObject *xc = (XcObject *)self;
- unsigned int dom;
- char *state_file;
- int progress = 1, ret;
+ u64 dom;
+ char *state_file;
+ int progress = 1, ret;
static char *kwd_list[] = { "dom", "state_file", "progress", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|i", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|i", kwd_list,
&dom, &state_file, &progress) )
return NULL;
char *state_file;
int progress = 1, ret;
+ u64 dom;
static char *kwd_list[] = { "state_file", "progress", NULL };
&state_file, &progress) )
return NULL;
- ret = xc_linux_restore(xc->xc_handle, state_file, progress);
-
- return PyInt_FromLong(ret);
+ ret = xc_linux_restore(xc->xc_handle, state_file, progress, &dom);
+ if ( ret < 0 )
+ return PyLong_FromLong(ret);
+
+ return PyLong_FromUnsignedLongLong(dom);
}
static PyObject *pyxc_linux_build(PyObject *self,
{
XcObject *xc = (XcObject *)self;
- unsigned int dom;
- char *image, *ramdisk = NULL, *cmdline = "";
- int ret;
+ u64 dom;
+ char *image, *ramdisk = NULL, *cmdline = "";
+ int ret;
static char *kwd_list[] = { "dom", "image", "ramdisk", "cmdline", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|ss", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|ss", kwd_list,
&dom, &image, &ramdisk, &cmdline) )
return NULL;
{
XcObject *xc = (XcObject *)self;
- unsigned int dom;
- char *image, *ramdisk = NULL, *cmdline = "";
- int ret;
+ u64 dom;
+ char *image, *ramdisk = NULL, *cmdline = "";
+ int ret;
static char *kwd_list[] = { "dom", "image", "ramdisk", "cmdline", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|ss", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|ss", kwd_list,
&dom, &image, &ramdisk, &cmdline) )
return NULL;
{
XcObject *xc = (XcObject *)self;
- unsigned int dom;
+ u64 dom;
unsigned long mcuadv, warp, warpl, warpu;
int ret;
static char *kwd_list[] = { "dom", "mcuadv", "warp", "warpl",
"warpu", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illll", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lllll", kwd_list,
&dom, &mcuadv, &warp, &warpl, &warpu) )
return NULL;
{
XcObject *xc = (XcObject *)self;
- unsigned int dom, vif;
+ u64 dom;
+ unsigned int vif;
xc_vif_sched_params_t sched = { 0, 0 };
int ret;
static char *kwd_list[] = { "dom", "vif", "credit_bytes",
"credit_usecs", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|ll", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li|ll", kwd_list,
&dom, &vif,
&sched.credit_bytes,
&sched.credit_usec) )
XcObject *xc = (XcObject *)self;
PyObject *dict;
- unsigned int dom, vif;
+ u64 dom;
+ unsigned int vif;
xc_vif_sched_params_t sched;
int ret;
static char *kwd_list[] = { "dom", "vif", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list,
&dom, &vif) )
return NULL;
XcObject *xc = (XcObject *)self;
PyObject *dict;
- unsigned int dom, vif;
+ u64 dom;
+ unsigned int vif;
xc_vif_stats_t stats;
- int ret;
+ int ret;
static char *kwd_list[] = { "dom", "vif", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list,
&dom, &vif) )
return NULL;
{
XcObject *xc = (XcObject *)self;
- unsigned int dom, vbd;
+ u64 dom;
+ unsigned int vbd;
int writeable, ret;
static char *kwd_list[] = { "dom", "vbd", "writeable", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lii", kwd_list,
&dom, &vbd, &writeable) )
return NULL;
{
XcObject *xc = (XcObject *)self;
- unsigned int dom, vbd;
+ u64 dom;
+ unsigned int vbd;
int ret;
static char *kwd_list[] = { "dom", "vbd", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list,
&dom, &vbd) )
return NULL;
{
XcObject *xc = (XcObject *)self;
- unsigned int dom, vbd;
+ u64 dom;
+ unsigned int vbd;
xc_vbdextent_t extent;
int ret;
static char *kwd_list[] = { "dom", "vbd", "device",
"start_sector", "nr_sectors", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiill", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Liill", kwd_list,
&dom, &vbd,
&extent.real_device,
&extent.start_sector,
{
XcObject *xc = (XcObject *)self;
- unsigned int dom, vbd;
- int ret;
+ u64 dom;
+ unsigned int vbd;
+ int ret;
static char *kwd_list[] = { "dom", "vbd", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list,
&dom, &vbd) )
return NULL;
XcObject *xc = (XcObject *)self;
PyObject *list, *dict, *obj;
- unsigned int dom, vbd;
+ u64 dom;
+ unsigned int vbd;
xc_vbdextent_t *extents = NULL;
int ret, i, nr_extents;
static char *kwd_list[] = { "dom", "vbd", "extents", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiO", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "LiO", kwd_list,
&dom, &vbd, &list) )
goto fail;
XcObject *xc = (XcObject *)self;
PyObject *list;
- unsigned int dom, vbd;
+ u64 dom;
+ unsigned int vbd;
xc_vbdextent_t *extents;
int i, nr_extents, max_extents;
static char *kwd_list[] = { "dom", "vbd", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list,
&dom, &vbd) )
return NULL;
XcObject *xc = (XcObject *)self;
PyObject *list;
- unsigned int dom = XC_VBDDOM_PROBE_ALL, max_vbds = 1024;
+ u64 dom = XC_VBDDOM_PROBE_ALL;
+ unsigned int max_vbds = 1024;
xc_vbd_t *info;
int nr_vbds, i;
static char *kwd_list[] = { "dom", "max_vbds", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|Li", kwd_list,
&dom, &max_vbds) )
return NULL;
{
PyList_SetItem(
list, i,
- Py_BuildValue("{s:i,s:i,s:i,s:l}",
+ Py_BuildValue("{s:L,s:i,s:i,s:l}",
"dom", info[i].domid,
"vbd", info[i].vbdid,
"writeable", !!(info[i].flags & XC_VBDF_WRITEABLE),
"Create a new domain.\n"
" mem_kb [int, 65536]: Memory allocation, in kilobytes.\n"
" name [str, '(anon)']: Informative textual name.\n\n"
- "Returns: [int] new domain identifier; -1 on error.\n" },
+ "Returns: [long] new domain identifier; -1 on error.\n" },
{ "domain_start",
(PyCFunction)pyxc_domain_start,
METH_VARARGS | METH_KEYWORDS, "\n"
"Start execution of a domain.\n"
- " dom [int]: Identifier of domain to be started.\n\n"
+ " dom [long]: Identifier of domain to be started.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_stop",
(PyCFunction)pyxc_domain_stop,
METH_VARARGS | METH_KEYWORDS, "\n"
"Stop execution of a domain.\n"
- " dom [int]: Identifier of domain to be stopped.\n\n"
+ " dom [long]: Identifier of domain to be stopped.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_destroy",
(PyCFunction)pyxc_domain_destroy,
METH_VARARGS | METH_KEYWORDS, "\n"
"Destroy a domain.\n"
- " dom [int]: Identifier of domain to be destroyed.\n"
+ " dom [long]: Identifier of domain to be destroyed.\n"
" force [int, 0]: Bool - force immediate destruction?\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
(PyCFunction)pyxc_domain_pincpu,
METH_VARARGS | METH_KEYWORDS, "\n"
"Pin a domain to a specified CPU.\n"
- " dom [int]: Identifier of domain to be destroyed.\n"
- " force [int, -1]: CPU to pin to, or -1 to unpin\n\n"
+ " dom [long]: Identifier of domain to be destroyed.\n"
+ " cpu [int, -1]: CPU to pin to, or -1 to unpin\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_getinfo",
(PyCFunction)pyxc_domain_getinfo,
METH_VARARGS | METH_KEYWORDS, "\n"
"Get information regarding a set of domains, in increasing id order.\n"
- " first_dom [int, 0]: First domain to retrieve info about.\n"
+ " first_dom [long, 0]: First domain to retrieve info about.\n"
" max_doms [int, 1024]: Maximum number of domains to retrieve info"
" about.\n\n"
"Returns: [list of dicts] if list length is less than 'max_doms'\n"
" parameter then there was an error, or the end of the\n"
" domain-id space was reached.\n"
- " dom [int]: Identifier of domain to which this info pertains\n"
+ " dom [long]: Identifier of domain to which this info pertains\n"
" cpu [int]: CPU to which this domain is bound\n"
" running [int]: Bool - is the domain currently running?\n"
" stopped [int]: Bool - is the domain suspended?\n"
(PyCFunction)pyxc_linux_save,
METH_VARARGS | METH_KEYWORDS, "\n"
"Save the CPU and memory state of a Linux guest OS.\n"
- " dom [int]: Identifier of domain to be saved.\n"
+ " dom [long]: Identifier of domain to be saved.\n"
" state_file [str]: Name of state file. Must not currently exist.\n"
" progress [int, 1]: Bool - display a running progress indication?\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
"Restore the CPU and memory state of a Linux guest OS.\n"
" state_file [str]: Name of state file. Must not currently exist.\n"
" progress [int, 1]: Bool - display a running progress indication?\n\n"
- "Returns: [int] new domain identifier on success; -1 on error.\n" },
+ "Returns: [long] new domain identifier on success; -1 on error.\n" },
{ "linux_build",
(PyCFunction)pyxc_linux_build,
METH_VARARGS | METH_KEYWORDS, "\n"
"Build a new Linux guest OS.\n"
- " dom [int]: Identifier of domain to build into.\n"
+ " dom [long]: Identifier of domain to build into.\n"
" image [str]: Name of kernel image file. May be gzipped.\n"
" ramdisk [str, n/a]: Name of ramdisk file, if any.\n"
" cmdline [str, n/a]: Kernel parameters, if any.\n\n"
- "Returns: [int] new domain identifier on success; -1 on error.\n" },
+ "Returns: [int] 0 on success; -1 on error.\n" },
{ "netbsd_build",
(PyCFunction)pyxc_netbsd_build,
METH_VARARGS | METH_KEYWORDS, "\n"
"Build a new NetBSD guest OS.\n"
- " dom [int]: Identifier of domain to build into.\n"
+ " dom [long]: Identifier of domain to build into.\n"
" image [str]: Name of kernel image file. May be gzipped.\n"
" cmdline [str, n/a]: Kernel parameters, if any.\n\n"
- "Returns: [int] new domain identifier on success; -1 on error.\n" },
+ "Returns: [int] 0 on success; -1 on error.\n" },
{ "bvtsched_global_set",
(PyCFunction)pyxc_bvtsched_global_set,
(PyCFunction)pyxc_bvtsched_domain_set,
METH_VARARGS | METH_KEYWORDS, "\n"
"Set per-domain tuning parameters for Borrowed Virtual Time scheduler.\n"
- " dom [int]: Identifier of domain to be tuned.\n"
- " mcuadv [int]: Internal BVT parameter.\n"
- " warp [int]: Internal BVT parameter.\n"
- " warpl [int]: Internal BVT parameter.\n"
- " warpu [int]: Internal BVT parameter.\n\n"
+ " dom [long]: Identifier of domain to be tuned.\n"
+ " mcuadv [int]: Internal BVT parameter.\n"
+ " warp [int]: Internal BVT parameter.\n"
+ " warpl [int]: Internal BVT parameter.\n"
+ " warpu [int]: Internal BVT parameter.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "vif_scheduler_set",
(PyCFunction)pyxc_vif_scheduler_set,
METH_VARARGS | METH_KEYWORDS, "\n"
"Set per-network-interface scheduling parameters.\n"
- " dom [int]: Identifier of domain to be adjusted.\n"
+ " dom [long]: Identifier of domain to be adjusted.\n"
" vif [int]: Identifier of VIF to be adjusted.\n"
" credit_bytes [int, 0]: Tx bytes permitted each interval.\n"
" credit_usecs [int, 0]: Interval, in usecs. 0 == no scheduling.\n\n"
(PyCFunction)pyxc_vif_scheduler_get,
METH_VARARGS | METH_KEYWORDS, "\n"
"Query the per-network-interface scheduling parameters.\n"
- " dom [int]: Identifier of domain to be queried.\n"
+ " dom [long]: Identifier of domain to be queried.\n"
" vif [int]: Identifier of VIF to be queried.\n\n"
"Returns: [dict] dictionary is empty on failure.\n"
" credit_bytes [int]: Tx bytes permitted each interval.\n"
(PyCFunction)pyxc_vif_stats_get,
METH_VARARGS | METH_KEYWORDS, "\n"
"Query the per-network-interface statistics.\n"
- " dom [int]: Identifier of domain to be queried.\n"
- " vif [int]: Identifier of VIF to be queried.\n\n"
+ " dom [long]: Identifier of domain to be queried.\n"
+ " vif [int]: Identifier of VIF to be queried.\n\n"
"Returns: [dict] dictionary is empty on failure.\n"
" tx_bytes [long]: Bytes transmitted.\n"
" tx_packets [long]: Packets transmitted.\n"
(PyCFunction)pyxc_vbd_create,
METH_VARARGS | METH_KEYWORDS, "\n"
"Create a new virtual block device associated with a given domain.\n"
- " dom [int]: Identifier of domain to get a new VBD.\n"
- " vbd [int]: Identifier for new VBD.\n"
- " writeable [int]: Bool - is the new VBD writeable?\n\n"
+ " dom [long]: Identifier of domain to get a new VBD.\n"
+ " vbd [int]: Identifier for new VBD.\n"
+ " writeable [int]: Bool - is the new VBD writeable?\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "vbd_destroy",
(PyCFunction)pyxc_vbd_destroy,
METH_VARARGS | METH_KEYWORDS, "\n"
"Destroy a virtual block device.\n"
- " dom [int]: Identifier of domain containing the VBD.\n"
- " vbd [int]: Identifier of the VBD.\n\n"
+ " dom [long]: Identifier of domain containing the VBD.\n"
+ " vbd [int]: Identifier of the VBD.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "vbd_grow",
(PyCFunction)pyxc_vbd_grow,
METH_VARARGS | METH_KEYWORDS, "\n"
"Grow a virtual block device by appending a new extent.\n"
- " dom [int]: Identifier of domain containing the VBD.\n"
- " vbd [int]: Identifier of the VBD.\n"
- " device [int]: Identifier of the real underlying block device.\n"
- " start_sector [int]: Real start sector of this extent.\n"
- " nr_sectors [int]: Length, in sectors, of this extent.\n\n"
+ " dom [long]: Identifier of domain containing the VBD.\n"
+ " vbd [int]: Identifier of the VBD.\n"
+ " device [int]: Identifier of the real underlying block device.\n"
+ " start_sector [int]: Real start sector of this extent.\n"
+ " nr_sectors [int]: Length, in sectors, of this extent.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "vbd_shrink",
(PyCFunction)pyxc_vbd_shrink,
METH_VARARGS | METH_KEYWORDS, "\n"
"Shrink a virtual block device by deleting its final extent.\n"
- " dom [int]: Identifier of domain containing the VBD.\n"
- " vbd [int]: Identifier of the VBD.\n\n"
+ " dom [long]: Identifier of domain containing the VBD.\n"
+ " vbd [int]: Identifier of the VBD.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "vbd_setextents",
(PyCFunction)pyxc_vbd_setextents,
METH_VARARGS | METH_KEYWORDS, "\n"
"Set all the extent information for a virtual block device.\n"
- " dom [int]: Identifier of domain containing the VBD.\n"
- " vbd [int]: Identifier of the VBD.\n"
+ " dom [long]: Identifier of domain containing the VBD.\n"
+ " vbd [int]: Identifier of the VBD.\n"
" extents [list of dicts]: Per-extent information.\n"
" device [int]: Identifier of the real underlying block device.\n"
" start_sector [int]: Real start sector of this extent.\n"
(PyCFunction)pyxc_vbd_getextents,
METH_VARARGS | METH_KEYWORDS, "\n"
"Get info on all the extents in a virtual block device.\n"
- " dom [int]: Identifier of domain containing the VBD.\n"
- " vbd [int]: Identifier of the VBD.\n\n"
+ " dom [long]: Identifier of domain containing the VBD.\n"
+ " vbd [int]: Identifier of the VBD.\n\n"
"Returns: [list of dicts] per-extent information; empty on error.\n"
" device [int]: Identifier of the real underlying block device.\n"
" start_sector [int]: Real start sector of this extent.\n"
(PyCFunction)pyxc_vbd_probe,
METH_VARARGS | METH_KEYWORDS, "\n"
"Get information regarding extant virtual block devices.\n"
- " dom [int, ALL]: Domain to query (default is to query all).\n"
+ " dom [long, ALL]: Domain to query (default is to query all).\n"
" max_vbds [int, 1024]: Maximum VBDs to query.\n\n"
"Returns: [list of dicts] if list length is less than 'max_vbds'\n"
" parameter then there was an error, or there were fewer vbds.\n"
- " dom [int]: Domain containing this VBD.\n"
- " vbd [int]: Domain-specific identifier of this VBD.\n"
- " writeable [int]: Bool - is this VBD writeable?\n"
- " nr_sectors [int]: Size of this VBD, in 512-byte sectors.\n" },
+ " dom [long]: Domain containing this VBD.\n"
+ " vbd [int]: Domain-specific identifier of this VBD.\n"
+ " writeable [int]: Bool - is this VBD writeable?\n"
+ " nr_sectors [int]: Size of this VBD, in 512-byte sectors.\n" },
{ "readconsolering",
(PyCFunction)pyxc_readconsolering,
{
__asm__("fninit");
if ( cpu_has_xmm ) load_mxcsr(0x1f80);
- current->flags |= PF_DONEFPUINIT;
+ set_bit(PF_DONEFPUINIT, ¤t->flags);
}
static inline void __save_init_fpu( struct task_struct *tsk )
asm volatile( "fnsave %0 ; fwait"
: "=m" (tsk->thread.i387.fsave) );
}
- tsk->flags &= ~PF_USEDFPU;
+ clear_bit(PF_USEDFPU, &tsk->flags);
}
void save_init_fpu( struct task_struct *tsk )
* This causes us to set the real flag, so we'll need
* to temporarily clear it while saving f-p state.
*/
- if ( tsk->flags & PF_GUEST_STTS ) clts();
+ if ( test_bit(PF_GUEST_STTS, &tsk->flags) ) clts();
__save_init_fpu(tsk);
stts();
}
pdb_out_buffer[buf_idx++] = 'm';
while ( (p = p->next_task) != &idle0_task )
{
- int domain = p->domain + PDB_DOMAIN_OFFSET;
+ domid_t domain = p->domain + PDB_DOMAIN_OFFSET;
if (count > 0)
pdb_out_buffer[buf_idx++] = ',';
/* XXX Currently the 'domain' field is ignored! XXX */
-long do_iopl(unsigned int domain, unsigned int new_io_pl)
+long do_iopl(domid_t domain, unsigned int new_io_pl)
{
execution_context_t *ec = get_execution_context();
ec->eflags = (ec->eflags & 0xffffcfff) | ((new_io_pl&3) << 12);
if ( (idle = do_createdomain(IDLE_DOMAIN_ID, cpu)) == NULL )
panic("failed 'createdomain' for CPU %d", cpu);
-
+
+ set_bit(PF_IDLETASK, &idle->flags);
+
idle->mm.pagetable = mk_pagetable(__pa(idle_pg_table));
map_cpu_to_boot_apicid(cpu, apicid);
/* Prevent recursion. */
clts();
- if ( !(current->flags & PF_USEDFPU) )
+ if ( !test_bit(PF_USEDFPU, ¤t->flags) )
{
- if ( current->flags & PF_DONEFPUINIT )
+ if ( test_bit(PF_DONEFPUINIT, ¤t->flags) )
restore_fpu(current);
else
init_fpu();
- current->flags |= PF_USEDFPU; /* So we fnsave on switch_to() */
+ set_bit(PF_USEDFPU, ¤t->flags); /* so we fnsave on switch_to() */
}
- if ( current->flags & PF_GUEST_STTS )
+ if ( test_and_clear_bit(PF_GUEST_STTS, ¤t->flags) )
{
struct guest_trap_bounce *gtb = guest_trap_bounce+smp_processor_id();
gtb->flags = GTBF_TRAP_NOCODE;
gtb->cs = current->thread.traps[7].cs;
gtb->eip = current->thread.traps[7].address;
- current->flags &= ~PF_GUEST_STTS;
}
}
long do_fpu_taskswitch(void)
{
- current->flags |= PF_GUEST_STTS;
+ set_bit(PF_GUEST_STTS, ¤t->flags);
stts();
return 0;
}
+++ /dev/null
-/* block.c
- *
- * ring data structures for buffering messages between hypervisor and
- * guestos's.
- *
- */
-
-#include <hypervisor-ifs/block.h>
-#include <xeno/lib.h>
-
-/*
- * create_block_ring
- *
- * domain:
- *
- * allocates space for a particular domain's block io ring.
- */
-blk_ring_t *create_block_ring(int domain)
-{
- printk ("XEN create block ring <not implemented>");
- return (blk_ring_t *)NULL;
-}
/* adapted from asm-xeno/page.h */
-static inline unsigned long machine_to_phys(int domain, unsigned long machine)
+static inline unsigned long machine_to_phys(domid_t domain,
+ unsigned long machine)
{
unsigned long phys;
pdb_get_values(domain, (u_char *) &phys,
- (unsigned long) machine_to_phys_mapping + (machine >> PAGE_SHIFT) * 4,
+ (unsigned long) machine_to_phys_mapping +
+ (machine >> PAGE_SHIFT) * 4,
sizeof(phys));
phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
return phys;
*/
/* read a byte from a process */
-u_char pdb_linux_get_value (int domain, int pid, unsigned long addr)
+u_char pdb_linux_get_value(domid_t domain, int pid, unsigned long addr)
{
u_char result = 0;
unsigned long task_struct_p, mm_p, pgd, task_struct_pid;
if (task_struct_p == (unsigned long)NULL)
{
/* oops */
- printk ("error: couldn't find process 0x%x in domain %d\n", pid, domain);
+ printk ("error: couldn't find process 0x%x in domain %llu\n", pid, domain);
return 0;
}
/****************************************************************************/
-extern int pdb_change_values (int domain, u_char *buffer, unsigned long addr,
- int length, int rw);
-extern u_char pdb_linux_get_value (int domain, int pid, unsigned long addr);
+extern int pdb_change_values(domid_t domain,
+ u_char *buffer, unsigned long addr,
+ int length, int rw);
+extern u_char pdb_linux_get_value(domid_t domain, int pid, unsigned long addr);
/*
* Set memory in a domain's address space
* THIS WILL BECOME A MACRO
*/
-int pdb_set_values (int domain, u_char *buffer, unsigned long addr, int length)
+int pdb_set_values(domid_t domain,
+ u_char *buffer, unsigned long addr, int length)
{
int count = pdb_change_values(domain, buffer, addr, length, 2);
* THIS WILL BECOME A MACRO
*/
-int pdb_get_values (int domain, u_char *buffer, unsigned long addr, int length)
+int pdb_get_values(domid_t domain,
+ u_char *buffer, unsigned long addr, int length)
{
return pdb_change_values(domain, buffer, addr, length, 1);
}
* RW: 1 = read, 2 = write
*/
-int pdb_change_values (int domain, u_char *buffer, unsigned long addr,
- int length, int rw)
+int pdb_change_values(domid_t domain, u_char *buffer, unsigned long addr,
+ int length, int rw)
{
struct task_struct *p;
l2_pgentry_t* l2_table = NULL;
{
op->u.debug.status = 0;
- TRC(printk("PDB: op:%c, dom:%x, in1:%x, in2:%x, in3:%x, in4:%x\n",
+ TRC(printk("PDB: op:%c, dom:%llu, in1:%x, in2:%x, in3:%x, in4:%x\n",
op->u.debug.opcode, op->u.debug.domain,
op->u.debug.in1, op->u.debug.in2,
op->u.debug.in3, op->u.debug.in4));
struct task_struct * p = find_domain_by_id(op->u.debug.domain);
if ( p != NULL )
{
- if ( (p->flags & PF_CONSTRUCTED) != 0 )
+ if ( test_bit(PF_CONSTRUCTED, &p->flags) )
{
wake_up(p);
reschedule(p);
/* Basically used to protect the domain-id space. */
static spinlock_t create_dom_lock = SPIN_LOCK_UNLOCKED;
-static unsigned int get_domnr(void)
+static domid_t get_domnr(void)
{
- static unsigned int domnr = 0;
- struct task_struct *p;
- int tries = 0;
-
- for ( tries = 0; tries < 1024; tries++ )
- {
- domnr = (domnr+1) & ((1<<20)-1);
- if ( (p = find_domain_by_id(domnr)) == NULL )
- return domnr;
- put_task_struct(p);
- }
-
- return 0;
+ static domid_t domnr = 0;
+ return ++domnr;
}
static int msr_cpu_mask;
ret = -EINVAL;
if ( p != NULL )
{
- if ( (p->flags & PF_CONSTRUCTED) != 0 )
+ if ( test_bit(PF_CONSTRUCTED, &p->flags) )
{
wake_up(p);
reschedule(p);
{
struct task_struct *p;
static unsigned int pro = 0;
- unsigned int dom;
+ domid_t dom;
ret = -ENOMEM;
spin_lock_irq(&create_dom_lock);
if ( op->u.createdomain.name[0] )
{
- strncpy (p->name, op->u.createdomain.name, MAX_DOMAIN_NAME);
- p->name[MAX_DOMAIN_NAME - 1] = 0;
+ strncpy(p->name, op->u.createdomain.name, MAX_DOMAIN_NAME);
+ p->name[MAX_DOMAIN_NAME - 1] = '\0';
}
ret = alloc_new_dom_mem(p, op->u.createdomain.memory_kb);
goto exit_create;
}
- ret = p->domain;
+ ret = 0;
- op->u.createdomain.domain = ret;
+ op->u.createdomain.domain = p->domain;
copy_to_user(u_dom0_op, op, sizeof(*op));
exit_create:
case DOM0_DESTROYDOMAIN:
{
- unsigned int dom = op->u.destroydomain.domain;
+ domid_t dom = op->u.destroydomain.domain;
int force = op->u.destroydomain.force;
ret = (dom == IDLE_DOMAIN_ID) ? -EPERM : kill_other_domain(dom, force);
}
case DOM0_ADJUSTDOM:
{
- unsigned int dom = op->u.adjustdom.domain;
+ domid_t dom = op->u.adjustdom.domain;
unsigned long mcu_adv = op->u.adjustdom.mcu_adv;
unsigned long warp = op->u.adjustdom.warp;
unsigned long warpl = op->u.adjustdom.warpl;
memcpy(&op->u.getdomaininfo.ctxt.i386_ctxt,
&p->shared_info->execution_context,
sizeof(p->shared_info->execution_context));
- if ( p->flags & PF_DONEFPUINIT )
+ if ( test_bit(PF_DONEFPUINIT, &p->flags) )
op->u.getdomaininfo.ctxt.flags |= ECF_I387_VALID;
memcpy(&op->u.getdomaininfo.ctxt.i387_ctxt,
&p->thread.i387,
{
struct pfn_info *page;
unsigned long pfn = op->u.getpageframeinfo.pfn;
- unsigned int dom = op->u.getpageframeinfo.domain;
+ domid_t dom = op->u.getpageframeinfo.domain;
struct task_struct *p;
ret = -EINVAL;
case DOM0_IOPL:
{
- extern long do_iopl(unsigned int, unsigned int);
+ extern long do_iopl(domid_t, unsigned int);
ret = do_iopl(op->u.iopl.domain, op->u.iopl.iopl);
}
break;
rwlock_t tasklist_lock __cacheline_aligned = RW_LOCK_UNLOCKED;
struct task_struct *task_hash[TASK_HASH_SIZE];
-struct task_struct *do_createdomain(unsigned int dom_id, unsigned int cpu)
+struct task_struct *do_createdomain(domid_t dom_id, unsigned int cpu)
{
int retval;
+ char buf[100];
struct task_struct *p = NULL;
unsigned long flags;
p->domain = dom_id;
p->processor = cpu;
- sprintf(p->name, "Domain-%d", dom_id);
+ /* We use a large intermediate to avoid overflow in sprintf. */
+ sprintf(buf, "Domain-%llu", dom_id);
+ strncpy(p->name, buf, MAX_DOMAIN_NAME);
+ p->name[MAX_DOMAIN_NAME-1] = '\0';
spin_lock_init(&p->blk_ring_lock);
spin_lock_init(&p->event_channel_lock);
}
-struct task_struct *find_domain_by_id(unsigned int dom)
+struct task_struct *find_domain_by_id(domid_t dom)
{
struct task_struct *p;
unsigned long flags;
void kill_domain_with_errmsg(const char *err)
{
- printk("DOM%d FATAL ERROR: %s\n",
- current->domain, err);
+ printk("DOM%llu FATAL ERROR: %s\n", current->domain, err);
kill_domain();
}
if ( !sched_rem_domain(p) )
return;
- printk("Killing domain %d\n", p->domain);
+ printk("Killing domain %llu\n", p->domain);
unlink_blkdev_info(p);
}
-long kill_other_domain(unsigned int dom, int force)
+long kill_other_domain(domid_t dom, int force)
{
struct task_struct *p;
unsigned long cpu_mask = 0;
__enter_scheduler();
}
-long stop_other_domain(unsigned int dom)
+long stop_other_domain(domid_t dom)
{
unsigned long cpu_mask;
struct task_struct *p;
if ( dom == 0 )
return -EINVAL;
- p = find_domain_by_id (dom);
+ p = find_domain_by_id(dom);
if ( p == NULL) return -ESRCH;
if ( p->state != TASK_STOPPED )
ASSERT(p->state == TASK_DYING);
ASSERT(!p->has_cpu);
- printk("Releasing task %d\n", p->domain);
+ printk("Releasing task %llu\n", p->domain);
/*
* This frees up blkdev rings and vbd-access lists. Totally safe since
unsigned long phys_l2tab;
int i;
- if ( (p->flags & PF_CONSTRUCTED) )
+ if ( test_bit(PF_CONSTRUCTED, &p->flags) )
return -EINVAL;
- p->flags &= ~PF_DONEFPUINIT;
+ clear_bit(PF_DONEFPUINIT, &p->flags);
if ( builddomain->ctxt.flags & ECF_I387_VALID )
- p->flags |= PF_DONEFPUINIT;
+ set_bit(PF_DONEFPUINIT, &p->flags);
memcpy(&p->shared_info->execution_context,
&builddomain->ctxt.i386_ctxt,
sizeof(p->shared_info->execution_context));
while ( builddomain->num_vifs-- > 0 )
(void)create_net_vif(p->domain);
- p->flags |= PF_CONSTRUCTED;
+ set_bit(PF_CONSTRUCTED, &p->flags);
return 0;
}
{
struct list_head *list_ent;
char *src, *vsrc, *dst, *data_start;
- int i, dom = p->domain;
+ int i;
+ domid_t dom = p->domain;
unsigned long phys_l1tab, phys_l2tab;
unsigned long cur_address, alloc_address;
unsigned long virt_load_address, virt_stack_address;
/* Sanity! */
if ( p->domain != 0 ) BUG();
- if ( (p->flags & PF_CONSTRUCTED) ) BUG();
+ if ( test_bit(PF_CONSTRUCTED, &p->flags) ) BUG();
/*
* This is all a bit grim. We've moved the modules to the "safe" physical
if ( strncmp(data_start, "XenoGues", 8) )
{
- printk("DOM%d: Invalid guest OS image\n", dom);
+ printk("DOM%llu: Invalid guest OS image\n", dom);
return -1;
}
virt_load_address = *(unsigned long *)(data_start + 8);
if ( (virt_load_address & (PAGE_SIZE-1)) )
{
- printk("DOM%d: Guest OS load address not page-aligned (%08lx)\n",
+ printk("DOM%llu: Guest OS load address not page-aligned (%08lx)\n",
dom, virt_load_address);
return -1;
}
if ( alloc_new_dom_mem(p, params->memory_kb) )
{
- printk("DOM%d: Not enough memory --- reduce dom0_mem ??\n", dom);
+ printk("DOM%llu: Not enough memory --- reduce dom0_mem ??\n", dom);
return -ENOMEM;
}
if ( data_len > (params->memory_kb << 9) )
{
- printk("DOM%d: Guest OS image is too large\n"
+ printk("DOM%llu: Guest OS image is too large\n"
" (%luMB is greater than %uMB limit for a\n"
" %uMB address space)\n",
dom, data_len>>20,
return -1;
}
- printk("DOM%d: Guest OS virtual load address is %08lx\n", dom,
+ printk("DOM%llu: Guest OS virtual load address is %08lx\n", dom,
virt_load_address);
SET_GDT_ENTRIES(p, DEFAULT_GDT_ENTRIES);
virt_startinfo_address->pt_base = virt_load_address +
((p->tot_pages - 1) << PAGE_SHIFT);
- virt_startinfo_address->dom_id = p->domain;
virt_startinfo_address->flags = 0;
if ( IS_PRIV(p) )
- {
virt_startinfo_address->flags |= SIF_PRIVILEGED;
- if ( CONSOLE_ISOWNER(p) )
- virt_startinfo_address->flags |= SIF_CONSOLE;
- }
+ if ( p->domain == 0 )
+ virt_startinfo_address->flags |= SIF_INITDOMAIN;
if ( initrd_len )
{
*dst = '\0';
/* If this guy's getting the console we'd better let go. */
- if ( virt_startinfo_address->flags & SIF_CONSOLE )
- {
- /* NB. Should reset the console here. */
+ if ( CONSOLE_ISOWNER(p) )
opt_console = 0;
- }
-
/* Reinstate the caller's page tables. */
write_cr3_counted(pagetable_val(current->mm.pagetable));
}
kfree(xd);
- p->flags |= PF_CONSTRUCTED;
+ set_bit(PF_CONSTRUCTED, &p->flags);
new_thread(p,
(unsigned long)virt_load_address,
new_dom = do_createdomain(0, 0);
if ( new_dom == NULL ) panic("Error creating domain 0\n");
+ set_bit(PF_PRIVILEGED, &new_dom->flags);
+
/*
* We're going to setup domain0 using the module(s) that we stashed safely
* above our MAX_DIRECTMAP_ADDRESS in boot/Boot.S The second module, if
unmap_domain_mem(skb_data);
- skb->dst_vif = find_vif_by_id(0);
+ skb->dst_vif = find_net_vif(0, 0);
(void)netif_rx(skb);
return 1;
spin_lock_irqsave(&console_lock, flags);
__putstr("DOM");
- sprintf(dom_id, "%d", current->domain);
+ sprintf(dom_id, "%llu", current->domain);
__putstr(dom_id);
__putstr(": ");
p = &idle0_task;
do {
- printk("Xen: DOM %d, CPU %d [has=%c], state = %s, "
+ printk("Xen: DOM %llu, CPU %d [has=%c], state = %s, "
"hyp_events = %08x\n",
p->domain, p->processor, p->has_cpu ? 'T':'F',
task_states[p->state], p->hyp_events);
-/* network.c
+/******************************************************************************
+ * network.c
*
* Network virtualization for Xen. Lower-level network interactions are in
* net/dev.c and in the drivers. This file contains routines to interact
* the use of rules.
*
* Copyright (c) 2002-2003, A K Warfield and K A Fraser
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <xeno/sched.h>
/* ----[ VIF Functions ]----------------------------------------------------*/
-net_vif_t *find_vif_by_id(unsigned long id)
+net_vif_t *find_net_vif(domid_t dom, unsigned int idx)
{
struct task_struct *p;
net_vif_t *vif = NULL;
- unsigned long flags, dom = id>>VIF_DOMAIN_SHIFT;
+ unsigned long flags;
read_lock_irqsave(&tasklist_lock, flags);
p = task_hash[TASK_HASH(dom)];
{
if ( p->domain == dom )
{
- vif = p->net_vif_list[id&VIF_INDEX_MASK];
- if ( vif != NULL ) get_vif(vif);
+ vif = p->net_vif_list[idx];
+ if ( vif != NULL )
+ get_vif(vif);
break;
}
p = p->next_hash;
}
-/* create_net_vif - Create a new vif and append it to the specified domain.
+/*
+ * create_net_vif - Create a new vif and append it to the specified domain.
*
- * the domain is examined to determine how many vifs currently are allocated
+ * The domain is examined to determine how many vifs currently are allocated
* and the newly allocated vif is appended. The vif is also added to the
* global list.
*
*/
-net_vif_t *create_net_vif(int domain)
+net_vif_t *create_net_vif(domid_t dom)
{
- int dom_vif_idx;
+ unsigned int idx;
net_vif_t *new_vif = NULL;
net_ring_t *new_ring = NULL;
struct task_struct *p = NULL;
unsigned long flags, vmac_hash;
unsigned char vmac_key[ETH_ALEN + 2 + MAX_DOMAIN_NAME];
- if ( !(p = find_domain_by_id(domain)) )
+ if ( (p = find_domain_by_id(dom)) == NULL )
return NULL;
write_lock_irqsave(&tasklist_lock, flags);
- for ( dom_vif_idx = 0; dom_vif_idx < MAX_DOMAIN_VIFS; dom_vif_idx++ )
- if ( p->net_vif_list[dom_vif_idx] == NULL ) break;
- if ( dom_vif_idx == MAX_DOMAIN_VIFS )
+ for ( idx = 0; idx < MAX_DOMAIN_VIFS; idx++ )
+ if ( p->net_vif_list[idx] == NULL )
+ break;
+ if ( idx == MAX_DOMAIN_VIFS )
goto fail;
if ( (new_vif = kmem_cache_alloc(net_vif_cache, GFP_KERNEL)) == NULL )
memset(new_vif, 0, sizeof(*new_vif));
- if ( sizeof(net_ring_t) > PAGE_SIZE ) BUG();
+ if ( sizeof(net_ring_t) > PAGE_SIZE )
+ BUG();
new_ring = (net_ring_t *)get_free_page(GFP_KERNEL);
clear_page(new_ring);
SHARE_PFN_WITH_DOMAIN(virt_to_page(new_ring), p);
*/
atomic_set(&new_vif->refcnt, 1);
new_vif->shared_rings = new_ring;
- new_vif->shared_idxs = &p->shared_info->net_idx[dom_vif_idx];
+ new_vif->shared_idxs = &p->shared_info->net_idx[idx];
new_vif->domain = p;
- new_vif->idx = dom_vif_idx;
+ new_vif->idx = idx;
new_vif->list.next = NULL;
spin_lock_init(&new_vif->rx_lock);
spin_lock_init(&new_vif->tx_lock);
new_vif->credit_usec = 0UL;
init_ac_timer(&new_vif->credit_timeout);
- if ( (p->domain == 0) && (dom_vif_idx == 0) )
+ if ( (p->domain == 0) && (idx == 0) )
{
/*
* DOM0/VIF0 gets the real physical MAC address, so that users can
* MAC addresses for some VIFs with no fear of clashes.
*/
memcpy(&vmac_key[0], the_dev->dev_addr, ETH_ALEN);
- *(__u16 *)(&vmac_key[ETH_ALEN]) = htons(dom_vif_idx);
+ *(__u16 *)(&vmac_key[ETH_ALEN]) = htons(idx);
strcpy(&vmac_key[ETH_ALEN+2], p->name);
vmac_hash = hash(vmac_key, ETH_ALEN + 2 + strlen(p->name));
memcpy(new_vif->vmac, "\xaa\x00\x00", 3);
new_vif->vmac[5] = (vmac_hash >> 0) & 0xff;
}
- p->net_vif_list[dom_vif_idx] = new_vif;
+ p->net_vif_list[idx] = new_vif;
write_unlock_irqrestore(&tasklist_lock, flags);
return new_vif;
}
-/* vif_query - Call from the proc file system to get a list of indexes
- * in use by a particular domain.
- */
int vif_query(vif_query_t *vq)
{
net_vif_t *vif;
int i;
int count = 0;
- if ( !(p = find_domain_by_id(vq->domain)) ) {
+ if ( (p = find_domain_by_id(vq->domain)) == NULL )
+ {
buf[0] = -1;
copy_to_user(vq->buf, buf, sizeof(int));
return -ESRCH;
return 0;
}
-/* vif_getinfo - Call from the proc file system to get info about a specific
- * vif in use by a particular domain.
- */
int vif_getinfo(vif_getinfo_t *info)
{
net_vif_t *vif;
- vif = find_vif_by_id((info->domain << VIF_DOMAIN_SHIFT) | info->vif);
- if ( vif == NULL )
+ if ( (vif = find_net_vif(info->domain, info->vif)) == NULL )
return -ESRCH;
info->total_bytes_sent = vif->total_bytes_sent;
{
net_vif_t *vif;
- vif = find_vif_by_id((params->domain << VIF_DOMAIN_SHIFT) | params->vif);
- if ( vif == NULL )
+ if ( (vif = find_net_vif(params->domain, params->vif)) == NULL )
return -ESRCH;
/* Turning off rate limiting? */
/* ----[ Net Rule Functions ]-----------------------------------------------*/
-/* add_net_rule - Add a new network filter rule.
- */
-
int add_net_rule(net_rule_t *rule)
{
net_rule_ent_t *new_ent;
return 0;
}
-/* delete_net_rule - Delete an existing network rule.
- */
-
int delete_net_rule(net_rule_t *rule)
{
- net_rule_ent_t *ent = net_rule_list, *prev = NULL;
- while ( (ent) && ((memcmp(rule, &ent->r, sizeof(net_rule_t))) != 0) )
- {
- prev = ent;
- ent = ent->next;
- }
+ net_rule_ent_t **pent, *ent;
+
+ write_lock(&net_rule_lock);
- if (ent != NULL)
+ for ( pent = &net_rule_list; pent != NULL; pent = &ent->next )
{
- write_lock(&net_rule_lock);
- if (prev != NULL)
+ ent = *pent;
+ if ( memcmp(rule, &ent->r, sizeof(net_rule_t)) == 0 )
{
- prev->next = ent->next;
- }
- else
- {
- net_rule_list = ent->next;
+ *pent = ent->next;
+ kmem_cache_free(net_rule_cache, ent);
+ break;
}
- kmem_cache_free(net_rule_cache, ent);
- write_unlock(&net_rule_lock);
}
+
+ write_unlock(&net_rule_lock);
return 0;
}
-/* print_net_rule - Print a single net rule.
- */
+static char *idx_to_name(unsigned int idx)
+{
+ if ( idx == VIF_PHYSICAL_INTERFACE )
+ return "PHYSICAL";
+ if ( idx == VIF_ANY_INTERFACE )
+ return "ANY";
+ return "UNKNOWN";
+}
+
+static char *print_ip_addr(char *buf, unsigned long addr)
+{
+ sprintf(buf, "%lu.%lu.%lu.%lu",
+ (addr>>24)&255, (addr>>16)&255, (addr>>8)&255, addr&255);
+ return buf;
+}
void print_net_rule(net_rule_t *r)
{
+ char buf[20];
+
printk("===] NET RULE:\n");
- printk("=] src_addr : %lu\n", (unsigned long) r->src_addr);
- printk("=] src_addr_mask : %lu\n", (unsigned long) r->src_addr_mask);
- printk("=] dst_addr : %lu\n", (unsigned long) r->dst_addr);
- printk("=] dst_addr_mask : %lu\n", (unsigned long) r->dst_addr_mask);
+ printk("=] src_addr : %s\n", print_ip_addr(buf, r->src_addr));
+ printk("=] src_addr_mask : %s\n", print_ip_addr(buf, r->src_addr_mask));
+ printk("=] dst_addr : %s\n", print_ip_addr(buf, r->dst_addr));
+ printk("=] dst_addr_mask : %s\n", print_ip_addr(buf, r->dst_addr_mask));
printk("=] src_port : %u\n", r->src_port);
printk("=] src_port_mask : %u\n", r->src_port_mask);
printk("=] dst_port : %u\n", r->dst_port);
printk("=] dst_port_mask : %u\n", r->dst_port_mask);
printk("=] dst_proto : %u\n", r->proto);
- switch ( r->src_vif )
- {
- case VIF_PHYSICAL_INTERFACE:
- printk("=] src_dom/idx : PHYSICAL\n");
- break;
- case VIF_ANY_INTERFACE:
- printk("=] src_dom/idx : ANY\n");
- break;
- default:
- printk("=] src_dom/idx : %lu/%lu\n",
- r->src_vif>>VIF_DOMAIN_SHIFT, r->src_vif&VIF_INDEX_MASK);
- break;
- }
- switch ( r->dst_vif )
- {
- case VIF_PHYSICAL_INTERFACE:
- printk("=] dst_dom/idx : PHYSICAL\n");
- break;
- case VIF_ANY_INTERFACE:
- printk("=] dst_dom/idx : ANY\n");
- break;
- default:
- printk("=] dst_dom/idx : %lu/%lu\n",
- r->dst_vif>>VIF_DOMAIN_SHIFT, r->dst_vif&VIF_INDEX_MASK);
- break;
- }
+
+ if ( r->src_dom == VIF_SPECIAL )
+ printk("=] src_dom/idx : %s\n", idx_to_name(r->src_idx));
+ else
+ printk("=] src_dom/idx : %llu/%u\n", r->src_dom, r->src_idx);
+
+ if ( r->dst_dom == VIF_SPECIAL )
+ printk("=] dst_dom/idx : %s\n", idx_to_name(r->dst_idx));
+ else
+ printk("=] dst_dom/idx : %llu/%u\n", r->dst_dom, r->dst_idx);
+
printk("=] action : %u\n", r->action);
}
-/* print_net_rule_list - Print the global rule table.
- */
-
-void print_net_rule_list()
+void print_net_rule_list(void)
{
net_rule_ent_t *ent;
int count = 0;
ent = net_rule_list;
- while (ent)
+ while ( ent != NULL )
{
print_net_rule(&ent->r);
ent = ent->next;
count++;
}
+
printk("\nTotal of %d rules.\n", count);
read_unlock(&net_rule_lock);
}
+
/* net_find_rule - Find the destination vif according to the current rules.
*
* Apply the rules to this skbuff and return the vif id that it is bound for.
*/
static net_vif_t *net_find_rule(u8 nproto, u8 tproto, u32 src_addr,
u32 dst_addr, u16 src_port,
- u16 dst_port, unsigned long src_vif)
+ u16 dst_port,
+ domid_t src_dom, unsigned int src_idx)
{
net_rule_ent_t *ent;
- unsigned long dest = VIF_UNKNOWN_INTERFACE;
+ domid_t dst_dom = VIF_SPECIAL;
+ unsigned int dst_idx = VIF_UNKNOWN_INTERFACE;
read_lock(&net_rule_lock);
while ( ent != NULL )
{
- if ( ((ent->r.src_vif == src_vif)
- || (ent->r.src_vif == VIF_ANY_INTERFACE)) &&
+ if ( (((ent->r.src_dom == src_dom) &&
+ (ent->r.src_idx == src_idx)) ||
+ ((ent->r.src_dom == VIF_SPECIAL) &&
+ (ent->r.src_idx == VIF_ANY_INTERFACE))) &&
- (src_vif != ent->r.dst_vif) &&
+ ((src_dom != ent->r.dst_dom) ||
+ (src_idx != ent->r.dst_idx)) &&
(!((ent->r.src_addr ^ src_addr) & ent->r.src_addr_mask )) &&
(!((ent->r.dst_addr ^ dst_addr) & ent->r.dst_addr_mask )) &&
(tproto == IPPROTO_UDP)))
)
{
+ dst_dom = ent->r.dst_dom;
+ dst_idx = ent->r.dst_idx;
/*
* XXX FFS! We keep going to find the "best" rule. Where best
* corresponds to vaguely sane routing of a packet. We need a less
* shafted model for our "virtual firewall/router" methinks!
*/
- if ( (dest & VIF_DOMAIN_MASK) == VIF_SPECIAL )
- dest = ent->r.dst_vif;
- if ( (dest & VIF_DOMAIN_MASK) != VIF_SPECIAL )
+ if ( dst_dom != VIF_SPECIAL )
break;
}
ent = ent->next;
read_unlock(&net_rule_lock);
- if ( dest == VIF_PHYSICAL_INTERFACE )
- return VIF_PHYS;
- else if ( (dest & VIF_DOMAIN_MASK) == VIF_SPECIAL )
+ if ( dst_dom == VIF_SPECIAL )
+ {
+ if ( dst_idx == VIF_PHYSICAL_INTERFACE )
+ return VIF_PHYS;
return VIF_DROP;
- else
- return find_vif_by_id(dest);
+ }
+
+ return find_net_vif(dst_dom, dst_idx);
}
/* net_get_target_vif - Find the vif that the given sk_buff is bound for.
{
net_vif_t *target = VIF_DROP;
u8 *h_raw, *nh_raw;
- unsigned long src_vif_val = VIF_PHYSICAL_INTERFACE;
+ domid_t src_dom = VIF_SPECIAL;
+ unsigned int src_idx = VIF_PHYSICAL_INTERFACE;
if ( src_vif != VIF_PHYS )
- src_vif_val = (src_vif->domain->domain<<VIF_DOMAIN_SHIFT) |
- src_vif->idx;
+ {
+ src_dom = src_vif->domain->domain;
+ src_idx = src_vif->idx;
+ }
- if ( len < ETH_HLEN ) goto drop;
+ if ( len < ETH_HLEN )
+ goto drop;
nh_raw = data + ETH_HLEN;
switch ( ntohs(*(unsigned short *)(data + 12)) )
if ( len < (ETH_HLEN + 28) ) goto drop;
target = net_find_rule((u8)ETH_P_ARP, 0, ntohl(*(u32 *)(nh_raw + 14)),
ntohl(*(u32 *)(nh_raw + 24)), 0, 0,
- src_vif_val);
+ src_dom, src_idx);
break;
case ETH_P_IP:
ntohl(*(u32 *)(nh_raw + 16)),
0,
0,
- src_vif_val);
+ src_dom, src_idx);
break;
}
return target;
drop:
- printk("VIF%lu/%lu: pkt to drop!\n",
- src_vif_val>>VIF_DOMAIN_SHIFT, src_vif_val&VIF_INDEX_MASK);
+ printk("VIF%llu/%u: pkt to drop!\n",
+ src_dom, src_idx);
return VIF_DROP;
}
}
/* Adjust scheduling parameter for a given domain. */
-long sched_adjdom(int dom, unsigned long mcu_adv, unsigned long warp,
+long sched_adjdom(domid_t dom, unsigned long mcu_adv, unsigned long warp,
unsigned long warpl, unsigned long warpu)
{
struct task_struct *p;
* 'next_prime's evt. Take context switch allowance into account.
*/
ASSERT(next_prime->evt >= next->evt);
+
r_time = ((next_prime->evt - next->evt)/next->mcu_advance) + ctx_allow;
sched_done:
(unsigned long) queue->next, (unsigned long) queue->prev);
list_for_each (list, queue) {
p = list_entry(list, struct task_struct, run_list);
- printk("%3d: %3d has=%c mcua=0x%04lX ev=0x%08X av=0x%08X c=0x%X%08X\n",
+ printk("%3d: %llu has=%c mcua=0x%04lX"
+ " ev=0x%08X av=0x%08X c=0x%X%08X\n",
loop++, p->domain,
p->has_cpu ? 'T':'F',
p->mcu_advance, p->evt, p->avt,
do {
if ( !is_idle_task(p) )
{
- printk("Domain: %d\n", p->domain);
+ printk("Domain: %llu\n", p->domain);
blk_ring = p->blk_ring_base;
printk(" req_prod:0x%08x, req_cons:0x%08x resp_prod:0x%08x/"
extern void restore_fpu( struct task_struct *tsk );
#define unlazy_fpu( tsk ) do { \
- if ( tsk->flags & PF_USEDFPU ) \
+ if ( test_bit(PF_USEDFPU, &tsk->flags) ) \
save_init_fpu( tsk ); \
} while (0)
#define clear_fpu( tsk ) do { \
- if ( tsk->flags & PF_USEDFPU ) { \
+ if ( test_and_clear_bit(PF_USEDFPU, &tsk->flags) ) { \
asm volatile("fwait"); \
- tsk->flags &= ~PF_USEDFPU; \
stts(); \
} \
} while (0)
extern void initialize_pdb(void);
/* Get/set values from generic debug interface. */
-extern int pdb_set_values (int domain, u_char *buffer,
- unsigned long addr, int length);
-extern int pdb_get_values (int domain, u_char *buffer,
- unsigned long addr, int length);
+extern int pdb_set_values(domid_t domain, u_char *buffer,
+ unsigned long addr, int length);
+extern int pdb_get_values(domid_t domain, u_char *buffer,
+ unsigned long addr, int length);
/* External entry points. */
extern int pdb_handle_exception(int exceptionVector,
unsigned short device; /* device number (opaque 16 bit val) */
unsigned short info; /* device type and flags */
unsigned long capacity; /* size in terms of #512 byte sectors */
- unsigned int domain; /* if a VBD, domain this 'belongs to' */
+ domid_t domain; /* if a VBD, domain this 'belongs to' */
} xen_disk_t;
typedef struct xen_disk_info
* This makes sure that old versions of dom0 tools will stop working in a
* well-defined way (rather than crashing the machine, for instance).
*/
-#define DOM0_INTERFACE_VERSION 0xAAAA0004
+#define DOM0_INTERFACE_VERSION 0xAAAA0005
/*
{
/* IN parameters. */
unsigned int memory_kb;
- char name[MAX_DOMAIN_NAME];
+ char name[MAX_DOMAIN_NAME];
/* OUT parameters. */
- unsigned int domain;
+ domid_t domain;
} dom0_createdomain_t;
#define DOM0_STARTDOMAIN 10
typedef struct dom0_startdomain_st
{
/* IN parameters. */
- unsigned int domain;
+ domid_t domain;
} dom0_startdomain_t;
#define DOM0_STOPDOMAIN 11
typedef struct dom0_stopdomain_st
{
/* IN parameters. */
- unsigned int domain;
+ domid_t domain;
} dom0_stopdomain_t;
#define DOM0_DESTROYDOMAIN 9
typedef struct dom0_destroydomain_st
{
/* IN variables. */
- unsigned int domain;
+ domid_t domain;
int force;
} dom0_destroydomain_t;
typedef struct dom0_getmemlist_st
{
/* IN variables. */
- unsigned int domain;
+ domid_t domain;
unsigned long max_pfns;
void *buffer;
/* OUT variables. */
typedef struct dom0_builddomain_st
{
/* IN variables. */
- unsigned int domain;
- unsigned int num_vifs;
+ domid_t domain;
+ unsigned int num_vifs;
full_execution_context_t ctxt;
} dom0_builddomain_t;
typedef struct dom0_adjustdom_st
{
/* IN variables. */
- unsigned int domain; /* domain id */
+ domid_t domain; /* domain id */
unsigned long mcu_adv; /* mcu advance: inverse of weight */
unsigned long warp; /* time warp */
unsigned long warpl; /* warp limit */
typedef struct dom0_getdomaininfo_st
{
/* IN variables. */
- unsigned int domain;
+ domid_t domain;
/* OUT variables. */
char name[MAX_DOMAIN_NAME];
int processor;
{
/* IN variables. */
unsigned long pfn; /* Machine page frame number to query. */
- unsigned int domain; /* To which domain does the frame belong? */
+ domid_t domain; /* To which domain does the frame belong? */
/* OUT variables. */
enum { NONE, L1TAB, L2TAB } type; /* Is the page PINNED to a type? */
} dom0_getpageframeinfo_t;
#define DOM0_IOPL 14
typedef struct dom0_iopl_st
{
- unsigned int domain;
+ domid_t domain;
unsigned int iopl;
} dom0_iopl_t;
{
/* IN variables. */
char opcode;
- unsigned int domain;
+ domid_t domain;
int in1, in2, in3, in4;
/* OUT variables. */
unsigned int status;
typedef struct dom0_pincpudomain_st
{
/* IN variables. */
- unsigned int domain;
+ domid_t domain;
int cpu; /* -1 implies unpin */
} dom0_pincpudomain_t;
#ifndef __ASSEMBLY__
+typedef u64 domid_t;
+/* DOMID_SELF is used in certain contexts to refer to oneself. */
+#define DOMID_SELF (~1ULL)
+
#include "network.h"
#include "block.h"
/* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */
unsigned long nr_pages; /* total pages allocated to this domain. */
unsigned long shared_info; /* MACHINE address of shared info struct.*/
- unsigned long dom_id; /* Domain identifier. */
unsigned long flags; /* SIF_xxx flags. */
/* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */
unsigned long pt_base; /* VIRTUAL address of page directory. */
/* These flags are passed in the 'flags' field of start_info_t. */
#define SIF_PRIVILEGED 1 /* Is the domain privileged? */
-#define SIF_CONSOLE 2 /* Does the domain own the physical console? */
+#define SIF_INITDOMAIN 2 /* Is thsi the initial control domain? */
/* For use in guest OSes. */
extern shared_info_t *HYPERVISOR_shared_info;
u16 src_port_mask;
u16 dst_port_mask;
u16 proto;
- unsigned long src_vif;
- unsigned long dst_vif;
+ domid_t src_dom, dst_dom;
+ unsigned int src_idx, dst_idx;
u16 action;
} net_rule_t;
-#define VIF_DOMAIN_MASK 0xfffff000UL
-#define VIF_DOMAIN_SHIFT 12
-#define VIF_INDEX_MASK 0x00000fffUL
-#define VIF_INDEX_SHIFT 0
-
-/* These are specified in the index if the dom is SPECIAL. */
-#define VIF_SPECIAL 0xfffff000UL
-#define VIF_UNKNOWN_INTERFACE (VIF_SPECIAL | 0)
-#define VIF_PHYSICAL_INTERFACE (VIF_SPECIAL | 1)
-#define VIF_ANY_INTERFACE (VIF_SPECIAL | 2)
+/* These are specified in the 'idx' if the 'dom' is SPECIAL. */
+#define VIF_SPECIAL (~0ULL)
+#define VIF_UNKNOWN_INTERFACE 0
+#define VIF_PHYSICAL_INTERFACE 1
+#define VIF_ANY_INTERFACE 2
typedef struct vif_query_st
{
- unsigned int domain;
+ domid_t domain;
int *buf; /* reply buffer -- guest virtual address */
} vif_query_t;
typedef struct vif_getinfo_st
{
- unsigned int domain;
+ domid_t domain;
unsigned int vif;
/* domain & vif are supplied by dom0, the rest are response fields */
*/
typedef struct vif_setparams_st
{
- unsigned int domain;
+ domid_t domain;
unsigned int vif;
unsigned long credit_bytes;
unsigned long credit_usec;
typedef struct _vbd_create {
- unsigned domain; /* create VBD for this domain */
+ domid_t domain; /* create VBD for this domain */
u16 vdevice; /* id by which dom will refer to VBD */
u16 mode; /* OR of { VBD_MODE_R , VBD_MODE_W } */
} vbd_create_t;
typedef struct _vbd_grow {
- unsigned domain; /* domain in question */
+ domid_t domain; /* domain in question */
u16 vdevice; /* 16 bit id domain refers to VBD as */
xen_extent_t extent; /* the extent to add to this VBD */
} vbd_grow_t;
typedef struct _vbd_shrink {
- unsigned domain; /* domain in question */
+ domid_t domain; /* domain in question */
u16 vdevice; /* 16 bit id domain refers to VBD as */
} vbd_shrink_t;
typedef struct _vbd_setextents {
- unsigned domain; /* domain in question */
+ domid_t domain; /* domain in question */
u16 vdevice; /* 16 bit id domain refers to VBD as */
u16 nr_extents; /* number of extents in the list */
xen_extent_t *extents; /* the extents to add to this VBD */
} vbd_setextents_t;
typedef struct _vbd_delete {
- unsigned domain; /* domain in question */
+ domid_t domain; /* domain in question */
u16 vdevice; /* 16 bit id domain refers to VBD as */
} vbd_delete_t;
-#define VBD_PROBE_ALL 0xFFFFFFFF
+#define VBD_PROBE_ALL (~0ULL)
typedef struct _vbd_probe {
- unsigned domain; /* domain in question or VBD_PROBE_ALL */
+ domid_t domain; /* domain in question or VBD_PROBE_ALL */
xen_disk_info_t xdi; /* where's our space for VBD/disk info */
} vbd_probe_t;
typedef struct _vbd_info {
/* IN variables */
- unsigned domain; /* domain in question */
+ domid_t domain; /* domain in question */
u16 vdevice; /* 16 bit id domain refers to VBD as */
u16 maxextents; /* max # of extents to return info for */
xen_extent_t *extents; /* pointer to space for extent list */
#define _HYP_EVENT_NEED_RESCHED 0
#define _HYP_EVENT_DIE 1
-#define PF_DONEFPUINIT 0x1 /* Has the FPU been initialised for this task? */
-#define PF_USEDFPU 0x2 /* Has this task used the FPU since last save? */
-#define PF_GUEST_STTS 0x4 /* Has the guest OS requested 'stts'? */
-#define PF_CONSTRUCTED 0x8 /* Has the guest OS been fully built yet? */
+#define PF_DONEFPUINIT 0 /* Has the FPU been initialised for this task? */
+#define PF_USEDFPU 1 /* Has this task used the FPU since last save? */
+#define PF_GUEST_STTS 2 /* Has the guest OS requested 'stts'? */
+#define PF_CONSTRUCTED 3 /* Has the guest OS been fully built yet? */
+#define PF_IDLETASK 4 /* Is this one of the per-CPU idle domains? */
+#define PF_PRIVILEGED 5 /* Is this domain privileged? */
#include <xeno/vif.h>
#include <xeno/vbd.h>
-/* SMH: replace below when have explicit 'priv' flag or bitmask */
-#define IS_PRIV(_p) ((_p)->domain == 0)
-
-#define DOMAIN_ID_BITS (16)
-#define MAX_DOMAIN_ID ((1<<(DOMAIN_ID_BITS))-1)
+#define IS_PRIV(_p) (test_bit(PF_PRIVILEGED, &(_p)->flags))
typedef struct event_channel_st
{
/*
* From here on things can be added and shuffled without special attention
*/
-
- unsigned int domain; /* domain id */
+
+ domid_t domain;
spinlock_t page_list_lock;
struct list_head page_list;
addr_limit: KERNEL_DS, \
thread: INIT_THREAD, \
prev_task: &(_t), \
- next_task: &(_t) \
+ next_task: &(_t), \
+ flags: 1<<PF_IDLETASK \
}
extern struct task_struct idle0_task;
extern struct task_struct *idle_task[NR_CPUS];
-#define IDLE_DOMAIN_ID (~0)
-#define is_idle_task(_p) ((_p)->domain == IDLE_DOMAIN_ID)
+#define IDLE_DOMAIN_ID (~0ULL)
+#define is_idle_task(_p) (test_bit(PF_IDLETASK, &(_p)->flags))
#include <xeno/slab.h>
atomic_inc(&(_p)->refcnt)
extern struct task_struct *do_createdomain(
- unsigned int dom_id, unsigned int cpu);
+ domid_t dom_id, unsigned int cpu);
extern int setup_guestos(
struct task_struct *p, dom0_createdomain_t *params, unsigned int num_vifs,
char *data_start, unsigned long data_len,
char *cmdline, unsigned long initrd_len);
extern int final_setup_guestos(struct task_struct *p, dom0_builddomain_t *);
-struct task_struct *find_domain_by_id(unsigned int dom);
+struct task_struct *find_domain_by_id(domid_t dom);
extern void release_task(struct task_struct *);
extern void __kill_domain(struct task_struct *p);
extern void kill_domain(void);
extern void kill_domain_with_errmsg(const char *err);
-extern long kill_other_domain(unsigned int dom, int force);
+extern long kill_other_domain(domid_t dom, int force);
extern void stop_domain(void);
-extern long stop_other_domain(unsigned int dom);
+extern long stop_other_domain(domid_t dom);
/* arch/process.c */
void new_thread(struct task_struct *p,
void sched_add_domain(struct task_struct *p);
int sched_rem_domain(struct task_struct *p);
long sched_bvtctl(unsigned long ctx_allow);
-long sched_adjdom(int dom, unsigned long mcu_adv, unsigned long warp,
+long sched_adjdom(domid_t dom, unsigned long mcu_adv, unsigned long warp,
unsigned long warpl, unsigned long warpu);
void init_idle_task(void);
void __wake_up(struct task_struct *p);
/* This hash table is protected by the tasklist_lock. */
#define TASK_HASH_SIZE 256
-#define TASK_HASH(_id) ((_id)&(TASK_HASH_SIZE-1))
+#define TASK_HASH(_id) ((int)(_id)&(TASK_HASH_SIZE-1))
extern struct task_struct *task_hash[TASK_HASH_SIZE];
#define REMOVE_LINKS(p) do { \
} while (0) \
/* vif prototypes */
-net_vif_t *create_net_vif(int domain);
+net_vif_t *create_net_vif(domid_t dom);
void destroy_net_vif(net_vif_t *vif);
void unlink_net_vif(net_vif_t *vif);
net_vif_t *net_get_target_vif(u8 *data, unsigned int len, net_vif_t *src_vif);
-net_vif_t *find_vif_by_id(unsigned long id);
+net_vif_t *find_net_vif(domid_t dom, unsigned int idx);
/*
* Return values from net_get_target_vif:
skb->data, skb->len, skb->src_vif);
if ( !VIF_LOCAL(skb->dst_vif) )
- skb->dst_vif = find_vif_by_id(0);
+ skb->dst_vif = find_net_vif(0, 0);
if ( skb->dst_vif != NULL )
{
/* Helpers, implemented at the bottom. */
u32 getipaddr(const char *buff, unsigned int len);
u16 antous(const char *buff, int len);
+u64 antoull(const char *buff, int len);
int anton(const char *buff, int len);
static int vfr_read_proc(char *page, char **start, off_t off,
/* NB. Prefix matches must go first! */
if (strncmp(&buffer[fs], "src", fl) == 0)
{
- op.u.net_rule.src_vif = VIF_ANY_INTERFACE;
+
+ op.u.net_rule.src_dom = VIF_SPECIAL;
+ op.u.net_rule.src_idx = VIF_ANY_INTERFACE;
}
else if (strncmp(&buffer[fs], "dst", fl) == 0)
{
- op.u.net_rule.dst_vif = VIF_PHYSICAL_INTERFACE;
+ op.u.net_rule.dst_dom = VIF_SPECIAL;
+ op.u.net_rule.dst_idx = VIF_PHYSICAL_INTERFACE;
}
else if (strncmp(&buffer[fs], "srcaddr", fl) == 0)
{
}
else if (strncmp(&buffer[fs], "srcdom", fl) == 0)
{
- op.u.net_rule.src_vif |= anton(&buffer[ts], tl)<<VIF_DOMAIN_SHIFT;
+ op.u.net_rule.src_dom = antoull(&buffer[ts], tl);
}
else if (strncmp(&buffer[fs], "srcidx", fl) == 0)
{
- op.u.net_rule.src_vif |= anton(&buffer[ts], tl);
+ op.u.net_rule.src_idx = anton(&buffer[ts], tl);
}
else if (strncmp(&buffer[fs], "dstdom", fl) == 0)
{
- op.u.net_rule.dst_vif |= anton(&buffer[ts], tl)<<VIF_DOMAIN_SHIFT;
+ op.u.net_rule.dst_dom = antoull(&buffer[ts], tl);
}
else if (strncmp(&buffer[fs], "dstidx", fl) == 0)
{
- op.u.net_rule.dst_vif |= anton(&buffer[ts], tl);
+ op.u.net_rule.dst_idx = anton(&buffer[ts], tl);
}
else if ( (strncmp(&buffer[fs], "proto", fl) == 0))
{
return ret;
}
+u64 antoull(const char *buff, int len)
+{
+ u64 ret;
+ char c;
+
+ ret = 0;
+
+ while ( (len) && ((c = *buff) >= '0') && (c <= '9') )
+ {
+ ret *= 10;
+ ret += c - '0';
+ buff++; len--;
+ }
+
+ return ret;
+}
+
u32 getipaddr(const char *buff, unsigned int len)
{
char c;
else
goto out;
- op.u.net_rule.src_vif = idx;
- op.u.net_rule.dst_vif = VIF_PHYSICAL_INTERFACE;
+ op.u.net_rule.src_dom = 0;
+ op.u.net_rule.src_idx = idx;
+ op.u.net_rule.dst_dom = VIF_SPECIAL;
+ op.u.net_rule.dst_idx = VIF_PHYSICAL_INTERFACE;
op.u.net_rule.src_addr = ntohl(ifa->ifa_address);
op.u.net_rule.src_addr_mask = ~0UL;
op.u.net_rule.dst_addr = 0;
op.u.net_rule.dst_addr_mask = 0;
(void)HYPERVISOR_network_op(&op);
- op.u.net_rule.src_vif = VIF_ANY_INTERFACE;
- op.u.net_rule.dst_vif = idx;
+ op.u.net_rule.src_dom = VIF_SPECIAL;
+ op.u.net_rule.src_idx = VIF_ANY_INTERFACE;
+ op.u.net_rule.dst_dom = 0;
+ op.u.net_rule.dst_idx = idx;
op.u.net_rule.src_addr = 0;
op.u.net_rule.src_addr_mask = 0;
op.u.net_rule.dst_addr = ntohl(ifa->ifa_address);
* addresses. All other domains have a privileged "parent" to do this for
* them at start of day.
*/
- if ( start_info.dom_id == 0 )
+ if ( start_info.flags & SIF_INITDOMAIN )
(void)register_inetaddr_notifier(¬ifier_inetdev);
err = request_irq(NET_IRQ, network_interrupt,
kfree(dev);
}
- if ( start_info.dom_id == 0 )
+ if ( start_info.flags & SIF_INITDOMAIN )
(void)unregister_inetaddr_notifier(¬ifier_inetdev);
}
#include <asm/desc.h>
/* Offsets in start_info structure */
-#define MOD_START 20
-#define MOD_LEN 24
+#define MOD_START 16
+#define MOD_LEN 20
startup_32:
cld
/* Force the change at ring 0. */
op.cmd = DOM0_IOPL;
- op.u.iopl.domain = start_info.dom_id;
+ op.u.iopl.domain = DOMID_SELF;
op.u.iopl.iopl = new_io_pl;
HYPERVISOR_dom0_op(&op);
{
dom0_op_t op;
op.cmd = DOM0_IOPL;
- op.u.iopl.domain = start_info.dom_id;
+ op.u.iopl.domain = DOMID_SELF;
op.u.iopl.iopl = next->io_pl;
queue_multicall1(__HYPERVISOR_dom0_op, (unsigned long)&op);
}
{
dom0_op_t op;
op.cmd = DOM0_IOPL;
- op.u.iopl.domain = start_info.dom_id;
+ op.u.iopl.domain = DOMID_SELF;
op.u.iopl.iopl = 1;
if( HYPERVISOR_dom0_op(&op) != 0 )
panic("Unable to obtain IOPL, despite being SIF_PRIVILEGED");
current->thread.io_pl = 1;
}
- if(start_info.flags & SIF_CONSOLE)
+ if ( start_info.flags & SIF_INITDOMAIN )
{
if( !(start_info.flags & SIF_PRIVILEGED) )
panic("Xen granted us console access but not privileged status");
{
struct timeval newtv;
- if ( !independent_wallclock && (start_info.dom_id != 0) )
+ if ( !independent_wallclock && !(start_info.flags & SIF_INITDOMAIN) )
return;
write_lock_irq(&xtime_lock);
last_update_from_xen = 0;
#ifdef CONFIG_XENO_PRIV
- if ( start_info.dom_id == 0 )
+ if ( start_info.flags & SIF_INITDOMAIN )
{
dom0_op_t op;
last_update_to_rtc = last_update_to_xen = 0;
}
#ifdef CONFIG_XENO_PRIV
- if ( (start_info.dom_id == 0) && ((time_status & STA_UNSYNC) == 0) )
+ if ( (start_info.flags & SIF_INITDOMAIN) &&
+ ((time_status & STA_UNSYNC) == 0) )
{
/* Send synchronised time to Xen approximately every minute. */
if ( xtime.tv_sec > (last_update_to_xen + 60) )
/* xenolinux/include/asm-xeno/keyboard.h */
/* Portions copyright (c) 2003 James Scott, Intel Research Cambridge */
-/* Talks to hypervisor to get PS/2 keyboard and mouse events, and send keyboard and mouse commands */
+/*
+ * Talks to hypervisor to get PS/2 keyboard and mouse events, and send keyboard
+ * and mouse commands
+ */
/* Based on:
* linux/include/asm-i386/keyboard.h
static inline int xen_kbd_controller_present ()
{
- return start_info.flags & SIF_CONSOLE;
+ return start_info.flags & SIF_INITDOMAIN;
}
/* resource allocation */